﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WizardSample
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        List<UserControl> wizardSteps = new List<UserControl>();
        private int stepCounter = 0;
        public MainWindow()
        {
            InitializeComponent();
        }

        private void btnNext_Click(object sender, RoutedEventArgs e)
        {            
            UserControl control= CreateStep(1);
            wizardSteps.Add(control);
            stepCounter = stepCounter + 1;
            wizardStep.IsEnabled = true;
            wizardStep.Visibility = Visibility.Visible;
        }

        public UserControl CreateStep(int stepNumber)
        {
            UserControl control = null;
            switch (stepNumber)
            {
                case 0:
                    if (wizardSteps.Count > 0)
                    {
                        control=wizardSteps[0] as UserControl;                       
                    }
                    else
                    {                        
                        control = new StepOne();     
                    }
                    control.IsEnabled = true;
                    control.Visibility = System.Windows.Visibility.Visible;
                    wizardStep.Content = control.Content;
                    break;
                case 1:
                    if (wizardSteps.Count > 1)
                    {
                        control = wizardSteps[1] as UserControl;                       
                    }
                    else
                    {                       
                        control=new StepTwo(); 
                    }
                    control.IsEnabled = true;
                    control.Visibility = System.Windows.Visibility.Visible;
                    wizardStep.Content = control.Content;
                    break;
                default:
                    break;
            }
            return control;
        }       
    }
}
